// queue.installPlugin(createjs.Sound);       //如果载入声音，必须先注册createjs.Sound
function loadAssest(){
    createjs.Ticker.setFPS(30);
    createjs.Ticker.addEventListener("tick",translateY)
    // 加载资源列表

    /*  {
          src : "http://o.cztvcloud.com/181/5127659/images/bg1.jpg",id : "bg1"
      },{
          src : "http://o.cztvcloud.com/181/5127659/images/bg10.jpg",id : "bg10"
      },{
          src : "http://o.cztvcloud.com/181/5127659/images/bg11.jpg",id : "bg11"
      },{
          src : "http://o.cztvcloud.com/181/5127659/images/bg12.jpg",id : "bg12"
      },{
          src : "http://o.cztvcloud.com/181/5127659/images/bg13.jpg",id : "bg13"
      },{
          src : "http://o.cztvcloud.com/181/5127659/images/bg14.jpg",id : "bg14"
      },{
          src : "http://o.cztvcloud.com/181/5127659/images/bg2.jpg",id : "bg2"
      },{
          src : "http://o.cztvcloud.com/181/5127659/images/bg3.jpg",id : "bg3"
      },{
          src : "http://o.cztvcloud.com/181/5127659/images/bg4.jpg",id : "bg4"
      },{
          src : "http://o.cztvcloud.com/181/5127659/images/bg5.jpg",id : "bg5"
      },{
          src : "http://o.cztvcloud.com/181/5127659/images/bg6.jpg",id : "bg6"
      },{
          src : "http://o.cztvcloud.com/181/5127659/images/bg7.jpg",id : "bg7"
      },{
          src : "http://o.cztvcloud.com/181/5127659/images/bg8.jpg",id : "bg8"
      },{
          src : "http://o.cztvcloud.com/181/5127659/images/bg9.jpg",id : "bg9"
      },*/
    manifest = [
        {
            src : "http://o.cztvcloud.com/181/5127659/images/bg5.jpg",id : "bg5"
        },{
            src : "http://o.cztvcloud.com/181/5127659/images/bubble.png",id : "bubble"
        },{
            src : "http://o.cztvcloud.com/181/5127659/images/fenxiang.jpg",id : "fenxiang"
        },{
            src : "http://o.cztvcloud.com/181/5127659/images/p1t1.png",id : "p1t1"
        },{
            src : "http://o.cztvcloud.com/181/5127659/images/p1t2.png",id : "p1t2"
        },{
            src : "http://o.cztvcloud.com/181/5127659/images/p1t3.png",id : "p1t3"
        },{
            src : "http://o.cztvcloud.com/181/5127659/images/p2flower.png",id : "p2flower"
        },{
            src : "http://o.cztvcloud.com/181/5127659/images/p5people.png",id : "p5people"
        },{
            src : "http://o.cztvcloud.com/181/5127659/images/group1.jpg",id : "group1"
        },{
            src : "http://o.cztvcloud.com/181/5127659/images/group2.jpg",id : "group2"
        },{
            src : "http://o.cztvcloud.com/181/5127659/images/group3.jpg",id : "group3"
        },{
            src : "http://o.cztvcloud.com/181/5127659/images/group4.jpg",id : "group4"
        },{
            src : "http://o.cztvcloud.com/181/5127659/images/group5.jpg",id : "group5"
        },{
            src : "http://o.cztvcloud.com/181/5127659/images/group6.jpg",id : "group6"
        },{
            src : "http://o.cztvcloud.com/181/5127659/images/group7.jpg",id : "group7"
        },{
            src : "http://o.cztvcloud.com/181/5127659/images/group8.jpg",id : "group8"
        },{
            src : "http://o.cztvcloud.com/181/5127659/images/group9.jpg",id : "group9"
        },{
            src : "http://o.cztvcloud.com/181/5127659/images/group10.jpg",id : "group10"
        },{
            src : "http://o.cztvcloud.com/181/5127659/images/group11.jpg",id : "group11"
        },{
            src : "http://o.cztvcloud.com/181/5127659/images/group12.jpg",id : "group12"
        },{
            src : "http://o.cztvcloud.com/181/5127659/images/group13.jpg",id : "group13"
        },{
            src : "http://o.cztvcloud.com/181/5127659/images/group14.jpg",id : "group14"
        }
    ]
    // 统计加载进度
    var loadCount = 0
    preload = new createjs.LoadQueue(false,"http://o.cztvcloud.com/181/5127659/images/");
    // 每加载成功一个资源回调一次
    preload.on("fileload",function(event){
        loadCount++
        document.querySelector("#process").innerHTML = ((loadCount * 100 / manifest.length).toFixed(0) - 1) + '%'
    })
    // 所有资源加载完毕后的回调
    preload.on('complete',function(event){
        startPaint()
        loadEnd()
    })
    preload.loadManifest(manifest)
    //第一个动画
    document.addEventListener("WeixinJSBridgeReady",function(e){
        console.log(e);
        document.getElementById('bg').load()
        document.getElementById('a1').load()
        document.getElementById('bg').play()
        gostart()
    },false);
    if(!isWeiXin()){
        gostart()
    }
}

// 帮助方法，方便创建图像
function createImage(stage,id,item){
    var image = new createjs.Bitmap(preload.getResult(id));
    image.width = item[0] * rem;
    image.height = item[1] * rem;
    image.x = -item[2] * rem;
    image.y = -item[3] * rem;
    image.alpha = 1;
    image.scale = item[4];
    image.regX = 0;
    image.regY = 0;
    stage.addChild(image)
    stage.update()
    return image
}

function startPaint(){
    var scale = [
        1,8,49,348,2000,16000,50000,400000,4200000,24000000,310000000,2700000000,14650000000,46329491284
    ]
    var item = [
        //[width,height,x,y,scale],
        [
            7.5,14.48,0,0,scale[0]
        ],[
            7.5,14.48,6.07 * scale[1] / scale[0],4.0 * scale[1] / scale[0],scale[1]
        ],[
            7.5,14.48,7.05 * scale[2] / scale[0],4.98 * scale[2] / scale[0],scale[2]
        ],[
            7.5,14.48,2.95 * scale[3] / scale[0],0.85 * scale[3] / scale[0],scale[3]
        ],[
            7.5,14.48,3.9 * scale[4] / scale[0],5.8 * scale[4] / scale[0],scale[4]
        ],[
            7.5,14.48,4 * scale[5] / scale[0],9.2 * scale[5] / scale[0],scale[5]
        ],[
            7.5,14.48,1.3 * scale[6] / scale[0],10.2 * scale[6] / scale[0],scale[6]
        ],[
            7.5,14.48,5.1 * scale[7] / scale[0],6.7 * scale[7] / scale[0],scale[7]
        ],[
            7.5,14.48,2.24 * scale[8] / scale[0],2.30 * scale[8] / scale[0],scale[8]
        ],[
            7.5,14.48,0.49 * scale[9] / scale[0],1.65 * scale[9] / scale[0],scale[9]
        ],[
            7.5,14.48,0.8 * scale[10] / scale[0],3.25 * scale[10] / scale[0],scale[10]
        ],[
            7.5,14.48,0.805 * scale[11] / scale[0],5.69 * scale[11] / scale[0],scale[11]
        ],[
            7.5,14.48,0.385 * scale[12] / scale[0],7.38 * scale[12] / scale[0],scale[12]
        ],[
            7.5,14.48,4 * scale[13] / scale[0],3 * scale[13] / scale[0],scale[13]
        ],
    ]
    // 第14页
    // bg14 = createImage(stage,'bg14',item[13])
    var groupsheet14 = {//创建一个动画实例
        "images"   : [preload.getResult('group14')],
        "frames"   : {
            "width"  : 750,            //每个图的高度为292，宽度为165，一共有64张图
            "height" : 1448,
            "count"  : 14
        },
        animations : {
            "start" : [0,13,'start',0.1]
        }
    }
    var spriteSheet14 = new createjs.SpriteSheet(groupsheet14);
    bg_am_14 = new createjs.Sprite(spriteSheet14);
    bg_am_14.width = item[13][0] * rem;
    bg_am_14.height = item[13][1] * rem;
    bg_am_14.x = -item[13][2] * rem;
    bg_am_14.y = -item[13][3] * rem;
    bg_am_14.alpha = 1;
    bg_am_14.scale = item[13][4];
    bg_am_14.regX = 0;
    bg_am_14.regY = 0;
    bg_am_14.scale = scale[13]
    stage.addChild(bg_am_14)
    stage.update()


    // 第13页
    // bg13 = createImage(stage,'bg13',item[12])
    var groupsheet13 = {//创建一个动画实例
        "images"   : [preload.getResult('group13')],
        "frames"   : {
            "width"  : 750,            //每个图的高度为292，宽度为165，一共有64张图
            "height" : 1448,
            "count"  : 20
        },
        animations : {
            "start" : [0,19,'start',0.1]
        }
    }
    var spriteSheet13 = new createjs.SpriteSheet(groupsheet13);
    bg_am_13 = new createjs.Sprite(spriteSheet13);
    bg_am_13.width = item[12][0] * rem;
    bg_am_13.height = item[12][1] * rem;
    bg_am_13.x = -item[12][2] * rem;
    bg_am_13.y = -item[12][3] * rem;
    bg_am_13.alpha = 1;
    bg_am_13.scale = item[12][4];
    bg_am_13.regX = 0;
    bg_am_13.regY = 0;
    bg_am_13.scale = scale[12]
    stage.addChild(bg_am_13)
    stage.update()
    // 第12页
    // bg12 = createImage(stage,'bg12',item[11])
    var groupsheet12 = {//创建一个动画实例
        "images"   : [preload.getResult('group12')],
        "frames"   : {
            "width"  : 750,            //每个图的高度为292，宽度为165，一共有64张图
            "height" : 365,
            "count"  : 10
        },
        animations : {
            "start" : [0,9,'start',0.1]
        }
    }
    var spriteSheet12 = new createjs.SpriteSheet(groupsheet12);
    bg_am_12 = new createjs.Sprite(spriteSheet12);
    bg_am_12.width = item[11][0] * rem;
    bg_am_12.height = item[11][1] * rem;
    bg_am_12.x = -item[11][2] * rem;
    bg_am_12.y = -item[11][3] * rem;
    bg_am_12.alpha = 1;
    bg_am_12.scale = item[11][4];
    bg_am_12.regX = 0;
    bg_am_12.regY = 0;
    bg_am_12.scale = scale[11]
    stage.addChild(bg_am_12)
    stage.update()

    // 第11页
    // bg11 = createImage(stage,'bg11',item[10])
    var groupsheet11 = {//创建一个动画实例
        "images"   : [preload.getResult('group11')],
        "frames"   : {
            "width"  : 750,            //每个图的高度为292，宽度为165，一共有64张图
            "height" : 1448,
            "count"  : 4
        },
        animations : {
            "start" : [0,3,'start',0.1]
        }
    }
    var spriteSheet11 = new createjs.SpriteSheet(groupsheet11);
    bg_am_11 = new createjs.Sprite(spriteSheet11);
    bg_am_11.width = item[10][0] * rem;
    bg_am_11.height = item[10][1] * rem;
    bg_am_11.x = -item[10][2] * rem;
    bg_am_11.y = -item[10][3] * rem;
    bg_am_11.alpha = 1;
    bg_am_11.scale = item[10][4];
    bg_am_11.regX = 0;
    bg_am_11.regY = 0;
    bg_am_11.scale = scale[10]
    stage.addChild(bg_am_11)
    stage.update()


    // 第10页
    // bg10 = createImage(stage,'bg10',item[9])
    var groupsheet10 = {//创建一个动画实例
        "images"   : [preload.getResult('group10')],
        "frames"   : {
            "width"  : 750,            //每个图的高度为292，宽度为165，一共有64张图
            "height" : 1448,
            "count"  : 4
        },
        animations : {
            "start" : [0,3,'start',0.1]
        }
    }
    var spriteSheet10 = new createjs.SpriteSheet(groupsheet10);
    bg_am_10 = new createjs.Sprite(spriteSheet10);
    bg_am_10.width = item[9][0] * rem;
    bg_am_10.height = item[9][1] * rem;
    bg_am_10.x = -item[9][2] * rem;
    bg_am_10.y = -item[9][3] * rem;
    bg_am_10.alpha = 1;
    bg_am_10.scale = item[9][4];
    bg_am_10.regX = 0;
    bg_am_10.regY = 0;
    bg_am_10.scale = scale[9]
    stage.addChild(bg_am_10)
    stage.update()


    // 第9页
    // bg9 = createImage(stage,'bg9',item[8])

    var groupsheet9 = {//创建一个动画实例
        "images"   : [preload.getResult('group9')],
        "frames"   : {
            "width"  : 750,            //每个图的高度为292，宽度为165，一共有64张图
            "height" : 1448,
            "count"  : 5
        },
        animations : {
            "start" : [0,4,'start',0.1]
        }
    }
    var spriteSheet9 = new createjs.SpriteSheet(groupsheet9);
    bg_am_9 = new createjs.Sprite(spriteSheet9);
    bg_am_9.width = item[8][0] * rem;
    bg_am_9.height = item[8][1] * rem;
    bg_am_9.x = -item[8][2] * rem;
    bg_am_9.y = -item[8][3] * rem;
    bg_am_9.alpha = 1;
    bg_am_9.scale = item[8][4];
    bg_am_9.regX = 0;
    bg_am_9.regY = 0;
    bg_am_9.scale = scale[8]
    stage.addChild(bg_am_9)
    stage.update()


    // 第8页
    // bg8 = createImage(stage,'bg8',item[7])

    var groupsheet8 = {//创建一个动画实例
        "images"   : [preload.getResult('group8')],
        "frames"   : {
            "width"  : 750,            //每个图的高度为292，宽度为165，一共有64张图
            "height" : 1448,
            "count"  : 5
        },
        animations : {
            "start" : [0,4,'start',0.1]
        }
    }
    var spriteSheet8 = new createjs.SpriteSheet(groupsheet8);
    bg_am_8 = new createjs.Sprite(spriteSheet8);
    bg_am_8.width = item[7][0] * rem;
    bg_am_8.height = item[7][1] * rem;
    bg_am_8.x = -item[7][2] * rem;
    bg_am_8.y = -item[7][3] * rem;
    bg_am_8.alpha = 1;
    bg_am_8.scale = item[7][4];
    bg_am_8.regX = 0;
    bg_am_8.regY = 0;
    bg_am_8.scale = scale[7]
    stage.addChild(bg_am_8)
    stage.update()


    // 第7页
    // bg7 = createImage(stage,'bg7',item[6])
    var groupsheet7 = {//创建一个动画实例
        "images"   : [preload.getResult('group7')],
        "frames"   : {
            "width"  : 750,            //每个图的高度为292，宽度为165，一共有64张图
            "height" : 1448,
            "count"  : 6
        },
        animations : {
            "start" : [0,5,'start',0.1]
        }
    }
    var spriteSheet7 = new createjs.SpriteSheet(groupsheet7);
    bg_am_7 = new createjs.Sprite(spriteSheet7);
    bg_am_7.width = item[6][0] * rem;
    bg_am_7.height = item[6][1] * rem;
    bg_am_7.x = -item[6][2] * rem;
    bg_am_7.y = -item[6][3] * rem;
    bg_am_7.alpha = 1;
    bg_am_7.scale = item[6][4];
    bg_am_7.regX = 0;
    bg_am_7.regY = 0;
    bg_am_7.scale = scale[6]
    stage.addChild(bg_am_7)
    stage.update()


    // 第6页
    // bg6 = createImage(stage,'bg6',item[5])
    var groupsheet6 = {//创建一个动画实例
        "images"   : [preload.getResult('group6')],
        "frames"   : {
            "width"  : 750,            //每个图的高度为292，宽度为165，一共有64张图
            "height" : 1448,
            "count"  : 10
        },
        animations : {
            "start" : [0,9,'start',0.1]
        }
    }
    var spriteSheet6 = new createjs.SpriteSheet(groupsheet6);
    bg_am_6 = new createjs.Sprite(spriteSheet6);
    bg_am_6.width = item[5][0] * rem;
    bg_am_6.height = item[5][1] * rem;
    bg_am_6.x = -item[5][2] * rem;
    bg_am_6.y = -item[5][3] * rem;
    bg_am_6.alpha = 1;
    bg_am_6.scale = item[5][4];
    bg_am_6.regX = 0;
    bg_am_6.regY = 0;
    bg_am_6.scale = scale[5]
    stage.addChild(bg_am_6)
    stage.update()


    // 第5页
    bg5 = createImage(stage,'bg5',item[4])

    // var groupsheet5 = {//创建一个动画实例
    //     "images"   : [preload.getResult('group5')],
    //     "frames"   : {
    //         "width"  : 750,            //每个图的高度为292，宽度为165，一共有64张图
    //         "height" : 1448,
    //         "count"  : 6
    //     },
    //     animations : {
    //         "start" : [0,5,'start',0.1]
    //     }
    // }
    // var spriteSheet5 = new createjs.SpriteSheet(groupsheet5);
    // bg_am_5 = new createjs.Sprite(spriteSheet5);
    // bg_am_5.width = item[4][0] * rem;
    // bg_am_5.height = item[4][1] * rem;
    // bg_am_5.x = -item[4][2] * rem;
    // bg_am_5.y = -item[4][3] * rem;
    // bg_am_5.alpha = 1;
    // bg_am_5.scale = item[4][4];
    // bg_am_5.regX = 0;
    // bg_am_5.regY = 0;
    // bg_am_5.scale = scale[4]
    // stage.addChild(bg_am_5)
    // stage.update()


    // 第4页
    // bg4 = createImage(stage,'bg4',item[3])
    // bg4.rotation = 180

    var groupsheet4 = {//创建一个动画实例
        "images"   : [preload.getResult('group4')],
        "frames"   : {
            "width"  : 750,            //每个图的高度为292，宽度为165，一共有64张图
            "height" : 1448,
            "count"  : 10
        },
        animations : {
            "start" : [0,9,'start',0.1]
        }
    }
    var spriteSheet4 = new createjs.SpriteSheet(groupsheet4);
    bg_am_4 = new createjs.Sprite(spriteSheet4);
    bg_am_4.width = item[3][0] * rem;
    bg_am_4.height = item[3][1] * rem;
    bg_am_4.x = -item[3][2] * rem;
    bg_am_4.y = -item[3][3] * rem;
    bg_am_4.alpha = 1;
    bg_am_4.scale = item[3][4];
    bg_am_4.regX = 0;
    bg_am_4.regY = 0;
    bg_am_4.scale = scale[3]
    stage.addChild(bg_am_4)
    stage.update()


    // 第3页
    // bg3 = createImage(stage,'bg3',item[2])

    var groupsheet3 = {//创建一个动画实例
        "images"   : [preload.getResult('group3')],
        "frames"   : {
            "width"  : 750,            //每个图的高度为292，宽度为165，一共有64张图
            "height" : 1448,
            "count"  : 4
        },
        animations : {
            "start" : [0,3,'start',0.1]
        }
    }
    var spriteSheet3 = new createjs.SpriteSheet(groupsheet3);
    bg_am_3 = new createjs.Sprite(spriteSheet3);
    bg_am_3.width = item[2][0] * rem;
    bg_am_3.height = item[2][1] * rem;
    bg_am_3.x = -item[2][2] * rem;
    bg_am_3.y = -item[2][3] * rem;
    bg_am_3.alpha = 1;
    bg_am_3.scale = item[2][4];
    bg_am_3.regX = 0;
    bg_am_3.regY = 0;
    bg_am_3.scale = scale[2]
    stage.addChild(bg_am_3)
    stage.update()


    // 第2页
    // bg2 = createImage(stage,'bg2',item[1])

    var groupsheet2 = {//创建一个动画实例
        "images"   : [preload.getResult('group2')],
        "frames"   : {
            "width"  : 750,            //每个图的高度为292，宽度为165，一共有64张图
            "height" : 1448,
            "count"  : 6
        },
        animations : {
            "start" : [0,5,'start',0.1]
        }
    }


    var spriteSheet2 = new createjs.SpriteSheet(groupsheet2);
    bg_am_2 = new createjs.Sprite(spriteSheet2);
    bg_am_2.width = item[1][0] * rem;
    bg_am_2.height = item[1][1] * rem;
    bg_am_2.x = -item[1][2] * rem;
    bg_am_2.y = -item[1][3] * rem;
    bg_am_2.alpha = 1;
    bg_am_2.scale = item[1][4];
    bg_am_2.regX = 0;
    bg_am_2.regY = 0;
    bg_am_2.scale = scale[1]
    stage.addChild(bg_am_2)
    stage.update()


    // 第一页

    // bg1 = createImage(stage,'bg1',item[0])
    // stage.scale = 10

    var groupsheet1 = {//创建一个动画实例
        "images"   : [preload.getResult('group1')],
        "frames"   : {
            "width"  : 750,            //每个图的高度为292，宽度为165，一共有64张图
            "height" : 1448,
            "count"  : 6
        },
        animations : {
            "start" : [0,5,'start',0.1]
        }
    }
    var spriteSheet = new createjs.SpriteSheet(groupsheet1);
    bg_am_1 = new createjs.Sprite(spriteSheet);
    bg_am_1.gotoAndPlay("start");
    bg_am_1.width = item[0][0] * rem;
    bg_am_1.height = item[0][1] * rem;
    bg_am_1.x = -item[0][2] * rem;
    bg_am_1.y = -item[0][3] * rem;
    bg_am_1.alpha = 1;
    bg_am_1.scale = item[0][4];
    bg_am_1.regX = 0;
    bg_am_1.regY = 0;
    bg_am_1.scale = canvas_scale
    stage.addChild(bg_am_1)
    stage.update()


    start = $('.start')
    start.bind('touchstart',function(){
        $('.start').css({
            "background"      : "url(\"http://o.cztvcloud.com/181/5127659/images/btn1.png\") no-repeat center center",
            "background-size" : "30%"
        })
        createjs.Ticker.paused = false; // un-pauses/resumes all of the tweens
    })
    start.bind('touchend',function(){
        createjs.Ticker.paused = true
        // createjs.Tween.get(stage).setPaused = true
        $('.start').css({
            "background"      : "url(\"http://o.cztvcloud.com/181/5127659/images/btn0.png\") no-repeat center center",
            "background-size" : "30%"
        })
    })
    time = 6000
    setTimeout(() =>{
        // var tweenease = createjs.Ease.quartInOut
        // var tweenease = createjs.Ease.linear
        var tweenease = createjs.Ease.quadOut
        var k = scale[0] / scale[1]
        createjs.Tween.get(stage).to({
            scale : k,x : item[1][2] * rem * k,y : item[1][3] * rem * k
        },time,tweenease).call(function(){
            console.log('第二页');
            k = scale[0] / scale[2]
            createjs.Tween.get(stage).to({
                scale : k,x : item[2][2] * rem * k,y : item[2][3] * rem * k
            },time,tweenease).call(function(){
                console.log('第3页');
                k = scale[0] / scale[3]
                createjs.Tween.get(stage).to({
                    scale : k,x : item[3][2] * rem * k,y : item[3][3] * rem * k
                },time,tweenease).call(function(){
                    console.log('第4页');
                    createjs.Ticker.paused = true
                    var a4 = ''
                    $('.start').hide()
                    setTimeout(() =>{
                        a4 = createjs.Sound.play("a4");
                        stage.removeChild(bg_am_2)
                        stage.removeChild(bg_am_3)

                        a4.on("complete",() =>{
                            setTimeout(() =>{
                                $('.start').show()
                            },1500)
                            dot3[2] = false
                        })
                    },1000)
                    createjs.Tween.get(bg_am_4).to({
                        rotation : 16,
                    },time / 2,tweenease)
                    k = scale[0] / scale[4]
                    createjs.Tween.get(stage).to({
                        scale : k,x : item[4][2] * rem * k,y : item[4][3] * rem * k
                    },time,tweenease).call(function(){

                        console.log('第5页');
                        k = scale[0] / scale[5]
                        createjs.Tween.get(stage).to({
                            scale : k,x : item[5][2] * rem * k,y : item[5][3] * rem * k
                        },time * 1.5,tweenease).call(function(){
                            console.log('第6页');
                            k = scale[0] / scale[6]
                            createjs.Tween.get(stage).to({
                                scale : k,x : item[6][2] * rem * k,y : item[6][3] * rem * k
                            },time * 0.7,tweenease).call(function(){
                                console.log('第7页');
                                createjs.Ticker.paused = true
                                //stage.removeChild(bg4)

                                stage.removeChild(bg_am_4)
                                stage.removeChild(bg_am_5)
                                stage.removeChild(bg5)
                                stage.removeChild(bg_am_6)
                                bg_am_7.gotoAndPlay('start')
                                $('.start').hide()
                                var a7 = createjs.Sound.play("a7");
                                a7.on("complete",() =>{
                                    setTimeout(() =>{
                                        $('.start').show()
                                        dot6[2] = false
                                    },1500)
                                })
                                k = scale[0] / scale[7]
                                bg_am_8.gotoAndPlay('start')
                                createjs.Tween.get(stage).to({
                                    scale : k,x : item[7][2] * rem * k,y : item[7][3] * rem * k
                                },time * 1.3,tweenease).call(function(){
                                    console.log('第8页');


                                    k = scale[0] / scale[8]
                                    createjs.Tween.get(stage).to({
                                        scale : k,x : item[8][2] * rem * k,y : item[8][3] * rem * k
                                    },time * 1.3,tweenease).call(function(){
                                        console.log('第9页');
                                        k = scale[0] / scale[9]
                                        createjs.Tween.get(stage).to({
                                            scale : k,x : item[9][2] * rem * k,y : item[9][3] * rem * k
                                        },time * 1.1,tweenease).call(function(){
                                            console.log('第10页');
                                            k = scale[0] / scale[10]
                                            createjs.Tween.get(stage).to({
                                                scale : k,x : item[10][2] * rem * k,y : item[10][3] * rem * k
                                            },time,tweenease).call(function(){
                                                createjs.Ticker.paused = true
                                                $('.start').hide()
                                                console.log('第11页');
                                                stage.removeChild(bg_am_9)
                                                stage.removeChild(bg_am_10)
                                                // bg_am_11.gotoAndPlay('start')
                                                var a11 = createjs.Sound.play("a11");//拍了结婚证
                                                a11.on("complete",() =>{
                                                    setTimeout(() =>{
                                                        $('.start').show()
                                                        dot10[2] = false
                                                    },1500)
                                                })
                                                k = scale[0] / scale[11]
                                                createjs.Tween.get(stage).to({
                                                    scale : k,x : item[11][2] * rem * k,y : item[11][3] * rem * k
                                                },6000,tweenease).call(function(){
                                                    console.log('第12页');
                                                    stage.removeChild(bg_am_8)
                                                    stage.removeChild(bg_am_9)
                                                    stage.removeChild(bg_am_10)
                                                    stage.removeChild(bg_am_11)

                                                    // bg10.alpha = 0
                                                    // bg11.alpha = 0
                                                    createjs.Tween.get(bg_am_12).to({
                                                        rotation : -13,
                                                    },time * 1.2,tweenease)
                                                    k = scale[0] / scale[12]
                                                    createjs.Tween.get(stage).to({
                                                        scale : k,x : item[12][2] * rem * k,y : item[12][3] * rem * k
                                                    },10000,tweenease).call(function(){


                                                        // $('.start').hide()
                                                        console.log('第13页');
                                                        stage.removeChild(bg_am_12)
                                                        stage.removeChild(bg_am_13)
                                                        k = scale[0] / scale[13]
                                                        createjs.Tween.get(stage).to({
                                                            scale : k,x : item[13][2] * rem * k,
                                                            y     : item[13][3] * rem * k
                                                        },time * 1,tweenease).call(() =>{
                                                            $('.start').hide()
                                                            console.log('end')
                                                            console.log('第14页');
                                                        })
                                                    })
                                                })
                                            })
                                        })
                                    })
                                })
                            })
                        })
                    })
                })
            })
        })
        createjs.Ticker.paused = true
    },0)
}

var rem = 100;
var bg_am_1 = ''
var bg_am_2 = ''
var bg_am_3 = ''
var bg_am_4 = ''
var bg_am_5 = ''
var bg_am_6 = ''
var bg_am_7 = ''
var bg_am_8 = ''
var bg_am_9 = ''
var bg_am_10 = ''
var bg_am_11 = ''
var bg_am_12 = ''
var bg_am_13 = ''
var bg_am_14 = ''
console.log("rem " + rem);

function end(){
    $('.prewrap').show()
    setTimeout(function(){
        $('.last1').show()
        setTimeout(function(){
            $('.last2').show()
            setTimeout(function(){
                $('.last3').show()
                setTimeout(function(){
                    $('.last3').show()
                    setTimeout(function(){
                        $('.sharepage').show()
                    },2500)
                },2000)
            },2000)
        },2000)
    },0)
}

function loadEnd(){
    var instance = ''
    var queue = new createjs.LoadQueue(false); //本地开发使用false即可
    queue.installPlugin(createjs.Sound);//如果载入声音，必须先注册createjs.Sound
    queue.on("complete",handleComplete,this);  //载入完成后调用
    //载入一个文件列表
    /*      {
                 id  : "bgmusic",
                 src : "http://v3.cztv.com/cztv/vod/2019/03/12/e4d64a71aafa472ab1cdee45078f4002/h264_128k_mp3.mp3"
             },

       {
           id  : "start",
           src : "http://v3.cztv.com/cztv/vod/2019/03/13/d359db68e45b45558940f830c4375bf5/h264_128k_mp3.mp3"
       },
       {
           id  : "a1",
           src : "http://v3.cztv.com/cztv/vod/2019/03/13/0d8acfdc435345749a89f1504b2ed38e/h264_128k_mp3.mp3"
       },*/
    queue.loadManifest([

        {
            id  : "a2",
            src : "http://v3.cztv.com/cztv/vod/2019/03/12/b61d9682c4e04bbc9907ffb3a405bd0c/h264_128k_mp3.mp3"
        },
        {
            id  : "a3",
            src : "http://v3.cztv.com/cztv/vod/2019/03/12/d966d66090154847ae204377875a6a29/h264_128k_mp3.mp3"
        },
        {
            id  : "a4",
            src : "http://v3.cztv.com/cztv/vod/2019/03/13/17a40dfebc814725a88f70c5b4d086dc/h264_128k_mp3.mp3"
        },
        {
            id  : "a5",
            src : "http://v3.cztv.com/cztv/vod/2019/03/13/b3dbcd20f01b401898d55c7c8e79a600/h264_128k_mp3.mp3"
        },
        {
            id  : "a6",
            src : "http://v3.cztv.com/cztv/vod/2019/03/12/8d43c9fcdad849109c0265d55eea40bb/h264_128k_mp3.mp3"
        },
        {
            id  : "a7",
            src : "http://v3.cztv.com/cztv/vod/2019/03/13/cf541ab440d4499680a4869b4eb6d141/h264_128k_mp3.mp3"
        },
        {
            id  : "a8",
            src : "http://v3.cztv.com/cztv/vod/2019/03/12/8a4ec8e948114c73b0f2a43ec74a240d/h264_128k_mp3.mp3"
        },
        {
            id  : "a9",
            src : "http://v3.cztv.com/cztv/vod/2019/03/13/97c851fbf1f54928ac4e2c978bfe3926/h264_128k_mp3.mp3"
        },
        {
            id  : "a10",
            src : "http://v3.cztv.com/cztv/vod/2019/03/12/82296ab691fa4e1290573445f2ff983f/h264_128k_mp3.mp3"
        },
        {
            id  : "a11",
            src : "http://v3.cztv.com/cztv/vod/2019/03/13/01fbc3d1a53944a385f228d34417aeaa/h264_128k_mp3.mp3"
        },
        {
            id  : "a12",
            src : "http://v3.cztv.com/cztv/vod/2019/03/13/91c3f0dd79584d3b8608a5a49896544c/h264_128k_mp3.mp3"
        },
        {
            id  : "a13",
            src : "http://v3.cztv.com/cztv/vod/2019/03/13/c527f4ea716e4f7092af9a10bbeef325/h264_128k_mp3.mp3"
        },
        {
            id  : "a14",
            src : "http://v3.cztv.com/cztv/vod/2019/03/12/a31737f47d8843ce8d3047723ecbd481/h264_128k_mp3.mp3"
        },
        {
            id  : "last",
            src : "http://v3.cztv.com/cztv/vod/2019/03/12/b91acf8732074d7093d4669fba6eae19/h264_128k_mp3.mp3"
        },
    ]);
    instance = ''

    function handleComplete(){
        console.log('loadcomplete')
    }
}

var dot1 = [1.1,3,true]    //a2
var dot2 = [10,50,true]    //a3
var dot3 = [0,0,true]
var dot4 = [485,2000,true]
var dot5 = [6000,15000,true]
var dot6 = [0,0,true]
var dot7 = [70530,282143,true]
var dot8 = [500529,1552511,true]
var dot9 = [17632734,20120445,true]
var dot10 = [0,0,true]
var dot11 = [509169334,2418837666,true]
var dot12 = [6041258327,12514553545,true]

function translateY(){
    stage.update()
    var scale = (1 / stage.scale).toFixed(2)
    // console.log(Math.floor(scale));
    if(dot1[2]){
        if(scale > dot1[0] && scale < dot1[1]){
            console.log('in1')
            dot1[2] = false;
            var a2 = createjs.Sound.play("a2");//找回了身份证
            stage.removeChild(bg_am_1)
            // setTimeout(() =>{
            //     stage.removeChild(bg_am_1), 3000
            // })
            bg_am_2.gotoAndPlay('start')
            // a2.volume = 0.8
        }
    } else if(dot2[2]){
        if(scale > dot2[0] && scale < dot2[1]){
            dot2[2] = false;
            bg_am_3.gotoAndPlay('start')
            var a3 = createjs.Sound.play("a3");//拍了结婚证
            stage.removeChild(bg_am_1)
            bg_am_4.gotoAndPlay('start')
        }
    } else if(dot3[2]){//死亡证明
    } else if(dot4[2]){//证明缩减，还能到家
        if(scale > dot4[0] && scale < dot4[1]){
            console.log('a5')
            dot4[2] = false;
            bg_am_3.gotoAndPlay('start')
            var a5 = createjs.Sound.play("a5");
        }
    } else if(dot5[2]){
        //最舒心的一次
        if(scale > dot5[0] && scale < dot5[1]){
            dot5[2] = false;
            // bg_am_5.gotoAndPlay('start')
            bg_am_6.gotoAndPlay('start')
            var a6 = createjs.Sound.play("a6");
        }
    } else if(dot6[2]){//找回儿子
    } else if(dot7[2]){



        //户口注销无法申请低保和残疾证
        if(scale > dot7[0] && scale < dot7[1]){
            dot7[2] = false;
            var a8 = createjs.Sound.play("a8");
            a8.on('complete',() =>{
                bg_am_9.gotoAndPlay('start')
                var a9 = createjs.Sound.play("a9");//民警找回
                a9.on('complete',() =>{
                    bg_am_10.gotoAndPlay('start')
                    bg_am_11.gotoAndPlay('start')
                    var a10 = createjs.Sound.play("a10");//感谢信
                })
            })
        }
    } else if(dot8[2]){
        if(scale > dot8[0] && scale < dot8[1]){
            dot8[2] = false;
        }
    } else if(dot9[2]){
        if(scale > dot9[0] && scale < dot9[1]){
            dot9[2] = false;
        }
    } else if(dot10[2]){//企业物联网项目
    } else if(dot11[2]){
        if(scale > dot11[0] && scale < dot11[1]){
            dot11[2] = false;
            bg_am_12.gotoAndPlay('start')
            var a12 = createjs.Sound.play("a12");//企业拿地
            a12.on('complete',() =>{
                bg_am_13.gotoAndPlay('start')
                bg_am_14.gotoAndPlay('start')
                var a13 = createjs.Sound.play("a13");//太多太繁琐的手续
                a13.on("complete",() =>{
                    stage.removeChild(bg_am_13)
                    var a14 = createjs.Sound.play("a14");//34天后
                    a14.on("complete",() =>{
                        var last = createjs.Sound.play("last");//下回分解
                        end()
                        $("#process").hide()
                        $('.prewrap').show()
                    })
                })
            })
        }
    } else if(dot12[2]){
        if(scale > dot12[0] && scale < dot12[1]){
            dot12[2] = false;
        }
    }
}


function isWeiXin(){
    //window.navigator.userAgent属性包含了浏览器类型、版本、操作系统类型、浏览器引擎类型等信息，这个属性可以用来判断浏览器类型
    var ua = window.navigator.userAgent.toLowerCase();
    //通过正则表达式匹配ua中是否含有MicroMessenger字符串
    if(ua.match(/MicroMessenger/i) == 'micromessenger'){
        return true;
    } else {
        return false;
    }
}

function gostart(){
    document.getElementById('bg').play()
    $('.loading').hide()
    $('.prewrap').css({
        "background"     : "url(\"http://o.cztvcloud.com/181/5127659/images/first.gif\") no-repeat top center",
        "backgroundSize" : "100% auto"
    })
    var start = document.getElementById('start')
    var a1 = document.getElementById('a1')
    start.play()
    setTimeout(function(){
        $('.ttsimg').attr('src','http://o.cztvcloud.com/181/5127659/images/t2.png')
        setTimeout(function(){
            $('.ttsimg').attr('src','http://o.cztvcloud.com/181/5127659/images/t3.png')
        },5000)
    },5200)
    start.addEventListener('ended',function(){
        $('#start').remove()
        $('.tts').hide()
        $('.prewrap').hide()
        a1.play()
    })
    a1.addEventListener('ended',function(){
        $('#a1').remove()
        console.log(" a1 over");
        $('.start').show()
    })
    // $('.prewrap,.tts').hide()
    // a1.play()
}